package gui;

import java.awt.BorderLayout;
import java.awt.Component;

/**
 *
 * @author Mariano Zapata
 */
public class DialogoArchivo extends javax.swing.JPanel implements Runnable {

    private Thread hilo;
    
    public static final int TIPO_TRANSFERIR= 0;
    public static final int TIPO_ELIMINAR= 1;
    public static final int TIPO_OBTENER= 2;
        
    /** Creates new form DialogoArchivo */
    public DialogoArchivo(int tipo)
    {
        initComponents();
        dialogo.getContentPane().setLayout(new BorderLayout());
        hilo= new Thread(this);
        switch (tipo)
        {
            case TIPO_TRANSFERIR:
                mensaje.setText("Transfiriendo archivo al Servidor, por favor espere...");
                break;
            case TIPO_ELIMINAR:
                mensaje.setText("Eliminando archivo del Servidor, por favor espere...");
                break;
            case TIPO_OBTENER:
                mensaje.setText("Obteniendo archivo desde el Servidor, por favor espere...");
                break;
        }
    }
    
    @Override
    public void run() {
        dialogo.setVisible(true);
        dialogo.dispose();
    }
    
    public void hacerVisible(Component c)
    {
        dialogo.getContentPane().add(this, BorderLayout.CENTER);
        dialogo.pack();
        dialogo.setLocationRelativeTo(c);
        hilo.start();
    }
    
    public void ocultar() {
        dialogo.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dialogo = new javax.swing.JDialog();
        mensaje = new javax.swing.JLabel();
        jProgressBar1 = new javax.swing.JProgressBar();

        dialogo.setModal(true);
        dialogo.setResizable(false);
        dialogo.setUndecorated(true);

        javax.swing.GroupLayout dialogoLayout = new javax.swing.GroupLayout(dialogo.getContentPane());
        dialogo.getContentPane().setLayout(dialogoLayout);
        dialogoLayout.setHorizontalGroup(
            dialogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        dialogoLayout.setVerticalGroup(
            dialogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setBackground(java.awt.Color.lightGray);
        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        mensaje.setFont(new java.awt.Font("Tahoma", 1, 11));
        mensaje.setText("jLabel1");

        jProgressBar1.setIndeterminate(true);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jProgressBar1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE)
                    .addComponent(mensaje, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mensaje)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDialog dialogo;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JLabel mensaje;
    // End of variables declaration//GEN-END:variables
}
